SDK Tutorial: How to create controllable characters
| Scenario = }} Tutorial by: JorisCeoen ''' In this tutorial I will try to explain the process of creating a controllable character in a map for Source SDK. This is an easy-to-do technique and unlike generally believed, very quickly created. Overview A couple of Zombie Escape maps have recently added a special feature called 'special characters' or 'controllable characters'. As the name suggests, this involves a player being able to control a certain character in the map (the character may be anything/anyone) and eventually control his powers. Needed entities * game_ui * any entity that can fire an output '''and also can have parented items onto it (knife or eventually a trigger_once) * prop_dynamic (= the model/character/person) * In this tutorial I will use an weapon stripper (player_weaponstrip) * plenty of optional triggers and relays that will not specifically be covered in this tutorial Tutorial (Basic) Step 1 (Aqcuiring player_weaponstrip) The player_weaponstrip is originally not included in the cstrike.fgd and as such is not standard in the entities list for CS:S. To fix this, go to the Tools tab inside the hammer and click Options... From here on there are 2 options: * Either you add the halflife2.fgd which can be found in C:\Program Files (x86)\Steam\steamapps\yourusername\sourcesdk\bin\ep1\bin or * You can download another .fgd right here which also contains the player_weaponstrip: http://www.mediafire.com/download.php?7aw5fola6oo62q3 Click on Add by the 'Game Data Files' field and add any of those 2 to the .fgd list. Once done, quit hammer entirely and restart Hammer. Step 2 (Placing entities) Place a game_ui somewhere in your map and name it to whatever you want, I'll name it 'character_ui'. Unflag all flags that are ticked! Place a knife or any other weapon that can fire an output at the spot you would like players to be able to pick up the special character. In this case I will use a weapon_knife where I will parent the model onto. Constrain the knife by ticking the 'Start constrained' flag. Make sure to name the knife, I will name it 'character_knife' Place a prop_dynamic with the desired character model (animated or non-animated doesn't really matter) right in the middle of the knife and set the name of the knife in the parent field of the prop_dynamic. Name it to whatever you want, I'll name it 'character_model' Place an player_weaponstrip anywhere in your map and name it to whatever you want, I'll name it 'weaponstripper'. Place a very small trigger_once around the knife or whatever weapon you used. Easiest to do is placing a trigger which has the same size as the bounding box of the knife. It doesn't has to be named unless you're going to kill it after it's been used. Step 3 (Adding outputs) In the trigger outputs that you put around the knife, set the following: OnTrigger -> name of the playerweaponstrip -> StripWeaponsAndSuit Which becomes this when taking the names used in this tutorial: OnTrigger -> weaponstripper -> StripWeaponsAndSuit In the knife its outputs field, enter the following: OnPickup -> name of the gameui -> Activate Which becomes this when taking the names used in this tutorial: OnPickup -> character_ui -> Activate So what we just did is simply stripping all the weapons (including the knife) of a player right before he can pick up the knife, and when he picks up the knife with the model parented to it he simultaneously activates the game_ui attached to it so that the player can fire outputs with both his movements as well as his attacks. Tip: You can also ignore the game_ui if you just want the character as a decorative element in the map rather than a controllable character. You can now play as anything or anyone else that you have as model parented to the knife in your map! It's always better to have an animated model but if you want to turn someone in a walkable static prop (with static prop I mean a prop that has no animation, I don't mean prop_static as an internal point entity) that's also possible. Here ends the basic tutorial. Pros * A very powerful addition to the map and the gameplay possibilities * Has a wide variety of outputs and can perform many complex systems in arguably no time Cons * The game_ui is notorious for it's massive lagg caused to the player controlling it. It doesn't lagg anything else in the server but the game_ui is sometimes (depending on the distance between the client (player) and the server) so laggy that controlling it can make your movement impossible to dominate. * Deactivating it will either crash the map or simply show an error in the console Category:SDK Tutorials